package io.gitee.sfch.chunmi.controller;

import io.gitee.sfch.chunmi.auth.SkipAuthentication;
import io.gitee.sfch.chunmi.entity.Response;
import io.gitee.sfch.chunmi.springframework.util.IpUtil;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SkipAuthentication
@RestController
@RequestMapping("/debug")
public class DebugController {

    /**
     * 判定系统是否能够正确应答
     */
    @GetMapping("ping")
    public String pingPong() {
        return "pong";
    }

    /**
     * 获取请求者的IP
     *
     * @param request 请求
     */
    @GetMapping("/ip")
    public Response<String> getClientIp(HttpServletRequest request) {
        return Response.success(IpUtil.getClientIp(request));
    }
}
